// pages/personalInformation/personalInformation.js
const app = getApp()
const pathUrl = app.globalData.pathUrl;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pickerIndex: '0', // 选择性别index
    orderPeriod: '私营企业', // 性别
    array: ['私营企业', '国营企业','其他'],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.setData({
      id: options.id
    });
    this.getOrderDetail();
  },
  // 获取主表详情
  getOrderDetail: function () {
    var that = this;
    wx.request({
      url: pathUrl + '/xdbuse/fxjBuse01/queryById',
      data: {
        id: that.data.id
      },
      success: function (res) {
        console.log(res);
        if (res.data.success) {
          that.setData({
            product: res.data.result
          });

        }
      },
      fail: function (res) { },
      complete: function () {
        console.log('11');
        // 获取基本信息
        wx.request({
          url: pathUrl + '/xdbuse/fxjBuse01/queryFxjBuse0110ByMainId',
          data: {
            id: that.data.id
          },
          success: function (res) {
            console.log(res);
            if (res.data.success) {
              that.setData({
                product01: res.data.result
              })
            }
          },
        });
      }
    });
  },
  // 单位名称
  query23Input: function(e){
    this.setData({
      query23: e.detail.value
    })
  },
  // 单位电话
  query26Input: function(e){
    this.setData({
      query26: e.detail.value
    })
  },
  // 职位
  query25Input: function(e){
    this.setData({
      query25: e.detail.value
    })
  },
  // 保存
  save: function(){
    var that = this;
    let data01 = {
      id: that.data.product.id,
      query01: that.data.product.query01,
      query02: that.data.product.query02,
      query03: that.data.product.query03,
      query04: that.data.product.query04,
      query05: that.data.product.query05,
      query06: that.data.query06,
      query07: that.data.query07,
      query08: that.data.query08,
      query09: that.data.product.query09,
      query10: that.data.product.query10,
      query11: that.data.product.query11,
      query12: that.data.product.query12,
      query13: that.data.product.query13,
      query14: that.data.product.query14,
      query15: that.data.product.query15,
      query16: that.data.product.query16,
      query17: that.data.product.query17,
      query18: that.data.product.query18,
      query19: that.data.product.query19,
      query20: that.data.product.query20,
      query21: that.data.product.query21,
      query22: that.data.product.query22,
      query23: that.data.product.query23,
      query24: that.data.product.query24,
      query25: that.data.product.query25,
      query26: that.data.product.query26,
      query27: that.data.product.query27,
      query28: that.data.product.query28,
      query29: that.data.product.query29,
      query30: that.data.product.query30,
      query31: that.data.product.query31,
      query32: that.data.product.query32,
      query33: that.data.product.query33,
      query34: that.data.product.query34,
      query35: that.data.product.query35,
      query36: that.data.product.query36,
      query37: that.data.product.query37,
      query38: that.data.product.query38,
      query39: that.data.product.query39,
      fxjBuse0110List: [{
        query03: that.data.product01[0].query03, // 订单编号
        query04: that.data.product01[0].query04, // 订单状态
        query05: that.data.product01[0].query05, // 申请产品
        query06: that.data.product01[0].query06, //电话
        query07: that.data.product01[0].query07, // 客户姓名
        query08: that.data.product01[0].query08, // 身份证
        query09: that.data.product01[0].query09, // 申请金额
        query10: that.data.product01[0].query10, // 申请利率
        query11: that.data.product01[0].query11, // 还款方式
        query12: that.data.product01[0].query12, // 申请期限
        query13: that.data.product01[0].query13, // 渠道代码
        query14: that.data.product01[0].query14, // 主借人姓名
        query15: that.data.product01[0].query15, // 联系电话
        query16: that.data.product01[0].query16, // 身份证号
        query17: that.data.product01[0].query17, // 配偶姓名
        query18: that.data.product01[0].query18, // 配偶电话
        query19: that.data.product01[0].query19, // 配偶身份证
        query20: that.data.product01[0].query20, // 共借人姓名
        query21: that.data.product01[0].query21, // 共借人电话
        query22: that.data.product01[0].query22, // 共借人身份证
        query23: that.data.query23, // 主借人单位
        query24: that.data.product01[0].query24, // 主借人部门
        query25: that.data.query25, // 主借人职位
        query26: that.data.query26, // 主借人单位电话
        query27: that.data.product01[0].query27, // 主借人地址
        query28: that.data.product01[0].query28, // 开户行
        query29: that.data.product01[0].query29 // 银行卡号
      }],
      fxjBuse0120List: [{
        query03: "",
        query04: "",
        query05: "",
        query06: ""
      }],
      fxjBuse0130List: [{
        query03: "",
        query04: "",
        query05: "",
        query06: "",
        query07: "",
        query08: ""
      }],
      fxjBuse0140List: [{
        query03: "",
        query04: "",
        query05: "",
        query06: "",
        query07: "",
        query08: "",
        query09: ""
      }],
      fxjBuse0150List: [{
        query03: "",
        query04: "",
        query05: "",
        query06: "",
        query07: ""
      }],
      fxjBuse0160List: [{
        query03: "",
        query04: "",
        query05: "",
        query06: "",
        query07: ""
      }],
    }
    wx.showLoading({
      title: '正在提交',
    });
    console.log(data01);
    wx.request({
      url: pathUrl + '/xdbuse/fxjBuse01/edit',
      method: 'PUT',
      data: data01,
      success: function (res) {
        console.log(res);
        console.log(data01)
        if (!res.data.success) {
          wx.showToast({
            title: '提交失败',
            icon: 'fail',
            duration: 1000
          });
        } else {
          wx.hideLoading();
          wx.showModal({
            title: '提示',
            content: '保存成功，返回上一页',
            success(res) {
              if (res.confirm) {
                wx.navigateBack({
                  delta: 1
                })
              } else if (res.cancel) {
                console.log('用户点击取消')
              }
            }
          });

        }
      },
      fail: function (res) { }
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})